/**
 * pipeline
 * 需要nodev10.0.0以上
 */

const fs = require('fs')

const { pipeline } = require('stream')
const zlib = require('zlib')

pipeline(
  fs.createReadStream('test.txt'),
  zlib.createGzip(),
  fs.createWriteStream('test.txt.gz'),
  (err) => {
    if (err) {
      console.log('管道架设失败', err)
    } else {
      console.log('管道架设成功')
    }
  }
)
